package model;

//import java.io.BufferedReader;
//import java.io.FileReader;
//import java.io.IOException;
//import java.io.InputStream;
import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;

//import javax.mail.Address;
//import javax.mail.Folder;
//import javax.mail.Message;
//import javax.mail.Multipart;
//import javax.mail.Session;
//import javax.mail.Store;

import org.hibernate.Criteria;
import org.hibernate.SessionFactory;
import org.jsoup.Jsoup;

import util.hibernate.HibernateUtil;

import databean.Email;
import databean.User;

public class EmailDAO {
	
	private UserDAO userDAO;
	
	public EmailDAO() {
		userDAO = new UserDAO();
		addDummyData();
	}
	
	public void createEmail(Email email) {
		
		org.hibernate.classic.Session session = null;
		
		try {
			
			SessionFactory sessionFactory = HibernateUtil.getSessionFactory();
			session = sessionFactory.openSession();
			
			Connection connection = session.connection();
			Statement statement = connection.createStatement();
			ResultSet result;

			//checking if same entry is already in database
			String query = "select emailID from email where userID='"+email.getUserID()+"'" +
					" and timestamp='"+email.getTimestamp()+"' and subject='"+email.getSubject()+"'" +
					" and sender='"+email.getSender()+"' and recipient='"+email.getRecipient()+"'";
			result = statement.executeQuery(query);
			
			//yes - ignore; no - add a new email record
			if (result.next() == true) {
				//ignore
			} else {
				
				//insert profile pic path
				User temp = userDAO.getUserByEmail(email.getSender());
				email.setSenderProfilePicPath(temp.getProfilePicPath());
				
				//start inserting
				org.hibernate.Transaction tx = session.beginTransaction();
	        	session.saveOrUpdate(email);
				tx.commit();
			}

			statement.close();
			result.close();
			
		} catch (Exception e) {
			e.printStackTrace();
		} finally {
			session.flush();
			session.close();
		}
	}
	
	public Email[] getAllEmails() {
		
		Email[] emails = null;
		org.hibernate.classic.Session session = null;
		
		try {
			
			SessionFactory sessionFactory = HibernateUtil.getSessionFactory();
			session = sessionFactory.openSession();

			Criteria crit = session.createCriteria(Email.class);
			
			@SuppressWarnings("unchecked")
			List<Email> dbEmails = crit.list();

			emails = new Email[dbEmails.size()];
			int num = 0;
			
			for(Iterator<Email> it = dbEmails.iterator();it.hasNext();){
				Email email = (Email) it.next();
				
				emails[num] = new Email();
				emails[num].setEmailID(email.getEmailID());
				emails[num].setUserID(email.getUserID());
				emails[num].setConversationID(email.getConversationID());
				emails[num].setOutlookID(email.getOutlookID());
				emails[num].setSender(email.getSender());
				emails[num].setRecipient(email.getRecipient());
				emails[num].setSubject(email.getSubject());
				emails[num].setTimestamp(email.getTimestamp());
				emails[num].setBody(email.getBody());
				emails[num].setNotes(email.getNotes());
				emails[num].setSenderProfilePicPath(email.getSenderProfilePicPath());
				emails[num].setStatus(email.getStatus());
				num++;
				
			}
			

		} catch (Exception e) {
			e.printStackTrace();
		} finally {
			session.flush();
			session.close();
		}
		
		return emails;
	}
	
	
	public ArrayList<Email> getUserEmails(long userID) throws java.sql.SQLException{
		
		ArrayList<Email> emails = new ArrayList<Email>();
		org.hibernate.classic.Session session = null;
		
		try {
			
			SessionFactory sessionFactory = HibernateUtil.getSessionFactory();
			session = sessionFactory.openSession();
			
			Connection connection = session.connection();
			Statement statement = connection.createStatement();
			ResultSet result;
			
			String query = "select * from email where userID='"+userID+"'";
			result = statement.executeQuery(query);
			
			while(result.next()){
				
				Email email = new Email();
				
				email.setEmailID(result.getLong("emailID"));
				email.setUserID(result.getLong("userID"));
				email.setConversationID(result.getLong("conversationID"));
				email.setOutlookID(result.getString("outlookID"));
				email.setTimestamp(result.getString("timestamp"));
				email.setSender(result.getString("sender"));
				email.setRecipient(result.getString("recipient"));
				email.setSubject(result.getString("subject"));
				email.setBody(result.getString("body"));
				email.setNotes(result.getString("notes"));
				email.setSenderProfilePicPath(result.getString("senderProfilePicPath"));
				email.setStatus(result.getString("status"));
										
				emails.add(email);		
				
			}
						
			statement.close();
			result.close();
			
			
		} catch (Exception e) {
			e.printStackTrace();
		} finally {
			session.flush();
			session.close();
		}
		
		return emails;
	}
	
	
	public Email getEmail(long emailID) throws java.sql.SQLException{
		
		Email email = null;
		org.hibernate.classic.Session session = null;
		
		try {
			
			SessionFactory sessionFactory = HibernateUtil.getSessionFactory();
			session = sessionFactory.openSession();
			
			Connection connection = session.connection();
			Statement statement = connection.createStatement();
			ResultSet result;
			
			String query = "select * from email where emailID='"+emailID+"'";
			result = statement.executeQuery(query);
			
			while(result.next()) {
				
				email = new Email();
				email.setEmailID(emailID);
				email.setUserID(result.getLong("userID"));
				email.setConversationID(result.getLong("conversationID"));
				email.setOutlookID(result.getString("outlookID"));
				email.setTimestamp(result.getString("timestamp"));
				email.setSender(result.getString("sender"));
				email.setRecipient(result.getString("recipient"));
				email.setSubject(result.getString("subject"));
				email.setBody(result.getString("body"));
				email.setNotes(result.getString("notes"));
				email.setSenderProfilePicPath(result.getString("senderProfilePicPath"));
				email.setStatus(result.getString("status"));
				
			}

			statement.close();
			result.close();
			
			
		} catch (Exception e) {
			e.printStackTrace();
		} finally {
			session.flush();
			session.close();
		}
		
		return email;
	}

	
	/**
	 * getEmailsByConversationID
	 * @param conversationID
	 * @return a list of Emails in descending order by emailID
	 * @throws java.sql.SQLException
	 */
	public ArrayList<Email> getEmailsByConversationID(long conversationID, long userID) throws java.sql.SQLException{
		
		ArrayList<Email> emails = new ArrayList<Email>();;
		Email email;
		org.hibernate.classic.Session session = null;
		
		try {
			
			SessionFactory sessionFactory = HibernateUtil.getSessionFactory();
			session = sessionFactory.openSession();

			Connection connection = session.connection();
			Statement statement = connection.createStatement();
			ResultSet result;
			
			String query = "select * from email where conversationID='"+conversationID+"' and userID='"+userID+"' order by emailID desc";
			result = statement.executeQuery(query);
			
			while(result.next()) {
				
				email = new Email();
				email.setEmailID(result.getLong("emailID"));
				email.setUserID(result.getLong("userID"));
				email.setConversationID(result.getLong("conversationID"));
				email.setOutlookID(result.getString("outlookID"));
				email.setTimestamp(result.getString("timestamp"));
				email.setSender(result.getString("sender"));
				email.setRecipient(result.getString("recipient"));
				email.setSubject(result.getString("subject"));
				email.setBody(result.getString("body"));
				email.setNotes(result.getString("notes"));
				email.setSenderProfilePicPath(result.getString("senderProfilePicPath"));
				email.setStatus(result.getString("status"));
				
				emails.add(email);
				
			}			
			

		} catch (Exception e) {
			e.printStackTrace();
		} finally {
			session.flush();
			session.close();
		}
		
		return emails;
		
	}
	
	
	public ArrayList<Email> getConversationIDs(long userID) throws java.sql.SQLException{
		
		ArrayList<Email> emails = new ArrayList<Email>();
		Email email;
		org.hibernate.classic.Session session = null;
		
		try {
			
			SessionFactory sessionFactory = HibernateUtil.getSessionFactory();
			session = sessionFactory.openSession();

			Connection connection = session.connection();
			Statement statement = connection.createStatement();
			ResultSet result;
			
			String query = "select conversationID,emailID,timestamp,sender,subject,recipient,body,status from email where userID='"+userID+"' order by emailID desc";
			result = statement.executeQuery(query);
			
			while(result.next()) {
				
				email = new Email();
				email.setEmailID(result.getLong("emailID"));
				email.setConversationID(result.getLong("conversationID"));
				email.setTimestamp(result.getString("timestamp"));
				email.setSender(result.getString("sender"));
				email.setRecipient(result.getString("recipient"));
				email.setSubject(result.getString("subject"));
				email.setBody(result.getString("body"));
				email.setStatus(result.getString("status"));
								
				emails.add(email);
				
			}
			
			
			//getting number of emails in a conversation
			int emailCount = 0;
			for (int i = 0; i<emails.size(); i++) {

				email = emails.get(i);
				emailCount = 1;

				for (int j = i+1; j<emails.size(); j++) {
					Email email2 = emails.get(j);
					
					if (email.getConversationID() == email2.getConversationID()) {
						emails.remove(j);
						j--;
						emailCount++;
					}
					
				}
				
				email.setEmailCount(emailCount);
				emails.set(i, email);
			}
			

		} catch (Exception e) {
			e.printStackTrace();
		} finally {
			session.flush();
			session.close();
		}
		
		return emails;
		
	}
	
	
	public boolean updateEmail(Email email) {
		
		org.hibernate.classic.Session session = null;
		
		try {
			
			SessionFactory sessionFactory = HibernateUtil.getSessionFactory();
			session = sessionFactory.openSession();
			
			org.hibernate.Transaction tx = session.beginTransaction();			
        	session.saveOrUpdate(email);
			tx.commit();
			
			
			
		} catch (Exception e) {
			e.printStackTrace();
			return false;
		} finally {
			session.flush();
			session.close();
		}
		
		return true;
	}
	

	public boolean deleteEmail(long emailID) {
		
		try {
			
			this.deleteEmail(this.getEmail(emailID));
			
		} catch (SQLException e1) {
			e1.printStackTrace();
			return false;
		}
		
		return true;
	}
	
	
	public boolean deleteEmail(Email email) {
		
		org.hibernate.classic.Session session = null;
		
		try {
			
			SessionFactory sessionFactory = HibernateUtil.getSessionFactory();
			session = sessionFactory.openSession();
			
			org.hibernate.Transaction tx = session.beginTransaction();			
        	session.delete(email);
			tx.commit();
			
			
		} catch (Exception e) {
			e.printStackTrace();
			return false;
		} finally {
			session.flush();
			session.close();
		}
		
		return true;
	}
	

	public static String html2text(String html) {
	    return Jsoup.parse(html).text();
	}
	
	
	public static String stringToHTMLString(String input) {
		
	    StringBuffer sb = new StringBuffer(input.length());

	    boolean blankCharacter = false;
	    
	    int len = input.length();
	    char c;

	    for (int i = 0; i < len; i++) {
	    	
	        c = input.charAt(i);
	        if (c == ' ') {

	            if (blankCharacter) {
	                blankCharacter = false;
	                sb.append("&nbsp;");
	            } else {
	                blankCharacter = true;
	                sb.append(' ');
	            }
	            
	        } else {
	        	
	            blankCharacter = false;

	            if (c == '"') {
	                sb.append("&quot;");
	            } else if (c == '>') {
	                sb.append("&gt;");
	            } else if (c == '&') {
	                sb.append("&amp;");
	            } else if (c == '<') {
	                sb.append("&lt;");
	            } else if (c == '\n') {
	                sb.append("&lt;br/&gt;");
	            } else {
	            	
	                int temp = 0xffff & c;
	                if (temp < 160) {
	                    //normal
	                    sb.append(c);
	                } else {
	                    //get unicode
	                    sb.append("&#");
	                    sb.append(new Integer(temp).toString());
	                    sb.append(';');
	                }
	                
	            }
	        }
	    }
	    
	    return sb.toString();
	    
	}
	
	
	public static String removeSubjectPrefix(String subject) {
		
		String result = subject;
		
		if (result.length()>4 && result.substring(0,4).equalsIgnoreCase("re: ")) {
			result = result.substring(4);
			if (result.length()>4) result = removeSubjectPrefix(result);
		}
		
		if (result.length()>4 && result.substring(0,4).equalsIgnoreCase("fw: ")) {
			result = result.substring(4);
			if (result.length()>4) result = removeSubjectPrefix(result);
		}
		
		if (result.length()>5 && result.substring(0,5).equalsIgnoreCase("fwd: ")) {
			result = result.substring(5);
			if (result.length()>4) result = removeSubjectPrefix(result);
		}
		
		if (result.length()>3 && result.substring(0, 3).equalsIgnoreCase("re:")) {
			result = result.substring(3);
			if (result.length()>4) result = removeSubjectPrefix(result);
		}
		
		if (result.length()>3 && result.substring(0,3).equalsIgnoreCase("fw:")) {
			result = result.substring(3);
			if (result.length()>4) result = removeSubjectPrefix(result);
		}
		
		if (result.length()>4 && result.substring(0,4).equalsIgnoreCase("fwd:")) {
			result = result.substring(4);
			if (result.length()>4) result = removeSubjectPrefix(result);
		}
		
		return result;
		
	}
	
	
	public static long retrieveConversationID(Email email) {
		
		org.hibernate.classic.Session session = null;
		long conversationID = -1;
		
		try {
			
			SessionFactory sessionFactory = HibernateUtil.getSessionFactory();
			session = sessionFactory.openSession();
			
			Connection connection = session.connection();
			Statement statement = connection.createStatement();
			ResultSet result;
			
			//retrieve subject and remove all prefixes (eg. re: fwd:)
			String subject = email.getSubject();
			subject = removeSubjectPrefix(subject);
			
			String query = "select conversationID from email where subject='"+subject+"'";
			result = statement.executeQuery(query);
			
			
			//yes - return a known conversationID
			if (result.next() == true) {
				conversationID = result.getLong("conversationID");

			//no  - return a new conversationID
			} else {

				query = "select conversationID from email order by conversationID desc limit 1";
				result = statement.executeQuery(query);
				
				//yes - return last conversationID + 1
				if (result.next() == true) {
					conversationID = result.getLong("conversationID") + 1;
				
				//no  - return 0 as initial conversationID
				} else {
					conversationID = 1;
				}
				
			}

			statement.close();
			result.close();
			
			
		} catch (Exception e) {
			e.printStackTrace();
		} finally {
			session.flush();
			session.close();
		}

		return conversationID;
	}
	
	
	public void addDummyData() {
		
		try {
			
			Email email;
			
			//Yong Kim - earilest at bottom
			//Set 1
		/*	email = new Email();
			email.setTimestamp("7/10/2011 02:00:01 PM Korean Standard Time");
			email.setUserID(userDAO.getUserIDByEmail("yong.kim@watson.bodado.info"));
			email.setOutlookID("yong.kim@watson.bodado.info");
			email.setSubject("Turtle TW-800 GSM Cell Phone Watch stock request");
			email.setSender("yong.kim@watson.bodado.info");
			email.setRecipient("xueshan.tan@croks.bodado.info");			
			email.setBody("Hi Susan," + "<br/><br/>" +" This is Yong Kim from Watson. I hope you still remember me? I purchased a batch of Turtle TW-800 GSM Cell Phone Watch from you a few weeks ago, and it has received amazing market response. We are planning another major rollout in Korea and are wondering whether you would be able to provide us with 8000 pieces by the end of October." + "<br/><br/>" +"Best Regards" + "<br/>" +"Yong Kim" + "<br/>" +"Purchasing Manager" + "<br/>" +"Watson, Inc.");
			email.setNotes(null);
			email.setStatus("New Message!");
			email.setConversationID(retrieveConversationID(email));
			createEmail(email);
			
			//change to xs tan
			email = new Email();
			email.setTimestamp("7/10/2011 02:00:01 PM Korean Standard Time");
			email.setUserID(userDAO.getUserIDByEmail("xueshan.tan@croks.bodado.info"));
			email.setOutlookID("xueshan.tan@croks.bodado.info");
			email.setSubject("Croks Mallika shoes request");
			email.setSender("yong.kim@watson.bodado.info");
			email.setRecipient("xueshan.tan@croks.bodado.info");			
			email.setBody("Hi Susan," + "<br/><br/>" +" This is Yong Kim from Watson. I hope you still remember me? I purchased a batch of Turtle TW-800 GSM Cell Phone Watch from you a few weeks ago, and it has received amazing market response. We are planning another major rollout in Korea and are wondering whether you would be able to provide us with 8000 pieces by the end of October." + "<br/><br/>" +"Best Regards" + "<br/>" +"Yong Kim" + "<br/>" +"Purchasing Manager" + "<br/>" +"Watson, Inc.");
			email.setNotes(null);
			email.setStatus("New Message!");
			email.setConversationID(retrieveConversationID(email));
			createEmail(email);
			
			//Set 2
			email = new Email();
			email.setTimestamp("7/10/2011 03:30:01 PM Eastern Standard Time");
			email.setUserID(userDAO.getUserIDByEmail("xueshan.tan@croks.bodado.info"));
			email.setOutlookID("xueshan.tan@croks.bodado.info");
			email.setSubject("Turtle TW-800 GSM Cell Phone Watch stock request");
			email.setSender("xueshan.tan@croks.bodado.info");
			email.setRecipient("yong.kim@watson.bodado.info");			
			email.setBody("Hi Yong," + "<br/><br/>" +" Thank you for your continued support. I have discussed about the request with my team, and the conclusion is that we would be able to provide you with the requested quantity by the specified deadline, only if we increase our staffs working hours. Hence, the price per item will correspondingly be increased slightly. May I know what opinion is on this is? Or would you prefer other alternatives?" + "<br/><br/>" +"Best Regards" + "<br/>" +"Susan Tan" + "<br/>" +"Sales and Marketing Manager" + "<br/>" +"WatchFactory, Inc.");
			email.setNotes(null);
			email.setStatus("New Message!");
			email.setConversationID(retrieveConversationID(email));
			createEmail(email);
			
			email = new Email();
			email.setTimestamp("7/10/2011 03:30:01 PM Eastern Standard Time");
			email.setUserID(userDAO.getUserIDByEmail("yong.kim@watson.bodado.info"));
			email.setOutlookID("yong.kim@watson.bodado.info");
			email.setSubject("Turtle TW-800 GSM Cell Phone Watch stock request");
			email.setSender("xueshan.tan@croks.bodado.info");
			email.setRecipient("yong.kim@watson.bodado.info");			
			email.setBody("Hi Yong," + "<br/><br/>" +" Thank you for your continued support. I have discussed about the request with my team, and the conclusion is that we would be able to provide you with the requested quantity by the specified deadline, only if we increase our staffs working hours. Hence, the price per item will correspondingly be increased slightly. May I know what opinion is on this is? Or would you prefer other alternatives?" + "<br/><br/>" +"Best Regards" + "<br/>" +"Susan Tan" + "<br/>" +"Sales and Marketing Manager" + "<br/>" +"WatchFactory, Inc.");
			email.setNotes(null);
			email.setStatus("New Message!");
			email.setConversationID(retrieveConversationID(email));
			createEmail(email);
			
			//Set 3
			email = new Email();
			email.setTimestamp("7/11/2011 10:30:01 AM Korean Standard Time");
			email.setUserID(userDAO.getUserIDByEmail("yong.kim@watson.bodado.info"));
			email.setOutlookID("yong.kim@watson.bodado.info");
			email.setSubject("Turtle TW-800 GSM Cell Phone Watch stock request");
			email.setSender("yong.kim@watson.bodado.info");
			email.setRecipient("xueshan.tan@croks.bodado.info");			
			email.setBody("May I know what is the proposed price increased?" + "<br/><br/>" +"Best Regards" + "<br/>" +"Yong Kim" + "<br/>" +"Purchasing Manager" + "<br/>" +"Watson, Inc.");
			email.setNotes(null);
			email.setStatus("New Message!");
			email.setConversationID(retrieveConversationID(email));
			createEmail(email);
			
			email = new Email();
			email.setTimestamp("7/11/2011 10:30:01 AM Korean Standard Time");
			email.setUserID(userDAO.getUserIDByEmail("xueshan.tan@croks.bodado.info"));
			email.setOutlookID("xueshan.tan@croks.bodado.info");
			email.setSubject("Turtle TW-800 GSM Cell Phone Watch stock request");
			email.setSender("yong.kim@watson.bodado.info");
			email.setRecipient("xueshan.tan@croks.bodado.info");			
			email.setBody("May I know what is the proposed price increased?" + "<br/><br/>" +"Best Regards" + "<br/>" +"Yong Kim" + "<br/>" +"Purchasing Manager" + "<br/>" +"Watson, Inc.");
			email.setNotes(null);
			email.setStatus("New Message!");
			email.setConversationID(retrieveConversationID(email));
			createEmail(email);
			
			//Set 4
			email = new Email();
			email.setTimestamp("7/11/2011 :30:01 AM Eastern Standard Time");
			email.setUserID(userDAO.getUserIDByEmail("xueshan.tan@croks.bodado.info"));
			email.setOutlookID("xueshan.tan@croks.bodado.info");
			email.setSubject("Turtle TW-800 GSM Cell Phone Watch stock request");
			email.setSender("xueshan.tan@croks.bodado.info");
			email.setRecipient("yong.kim@watson.bodado.info");			
			email.setBody("Hi Yong," + "<br/><br/>" +" Our proposed price change would be from USD 240 to USD 280." + "<br/><br/>" +"Best Regards" + "<br/>" +"Susan Tan" + "<br/>" +"Sales and Marketing Manager" + "<br/>" +"WatchFactory, Inc.");
			email.setNotes(null);
			email.setStatus("New Message!");
			email.setConversationID(retrieveConversationID(email));
			createEmail(email);
			
			email = new Email();
			email.setTimestamp("7/11/2011 :30:01 AM Eastern Standard Time");
			email.setUserID(userDAO.getUserIDByEmail("yong.kim@watson.bodado.info"));
			email.setOutlookID("yong.kim@watson.bodado.info");
			email.setSubject("Turtle TW-800 GSM Cell Phone Watch stock request");
			email.setSender("xueshan.tan@croks.bodado.info");
			email.setRecipient("yong.kim@watson.bodado.info");			
			email.setBody("Hi Yong," + "<br/><br/>" +" Our proposed price change would be from USD 240 to USD 280." + "<br/><br/>" +"Best Regards" + "<br/>" +"Susan Tan" + "<br/>" +"Sales and Marketing Manager" + "<br/>" +"WatchFactory, Inc.");
			email.setNotes(null);
			email.setStatus("New Message!");
			email.setConversationID(retrieveConversationID(email));
			createEmail(email);
			
			//Set 5
			email = new Email();
			email.setTimestamp("7/12/2011 10:30:01 AM Korean Standard Time");
			email.setUserID(userDAO.getUserIDByEmail("yong.kim@watson.bodado.info"));
			email.setOutlookID("yong.kim@watson.bodado.info");
			email.setSubject("Turtle TW-800 GSM Cell Phone Watch stock request");
			email.setSender("yong.kim@watson.bodado.info");
			email.setRecipient("xueshan.tan@croks.bodado.info");			
			email.setBody("Thanks for your prompt reply. Due to the price change, which we consider a little steep, I might have to get back to my team and discuss about it with them again. We'll let you know our decision ");
			email.setNotes(null);
			email.setStatus("New Message!");
			email.setConversationID(retrieveConversationID(email));
			createEmail(email);
			
			email = new Email();
			email.setTimestamp("7/12/2011 10:30:01 AM Korean Standard Time");
			email.setUserID(userDAO.getUserIDByEmail("xueshan.tan@croks.bodado.info"));
			email.setOutlookID("xueshan.tan@croks.bodado.info");
			email.setSubject("Turtle TW-800 GSM Cell Phone Watch stock request");
			email.setSender("yong.kim@watson.bodado.info");
			email.setRecipient("xueshan.tan@croks.bodado.info");			
			email.setBody("Thanks for your prompt reply. Due to the price change, which we consider a little steep, I might have to get back to my team and discuss about it with them again. We'll let you know our decision ");
			email.setNotes(null);
			email.setStatus("New Message!");
			email.setConversationID(retrieveConversationID(email));
			createEmail(email);
			
			//Jennifer Gates
			//Set 1
			email = new Email();
			email.setTimestamp("7/12/2011 10:45:01 AM Pacific Daylight Time");
			email.setUserID(userDAO.getUserIDByEmail("jennifer.gates@macrowat.bodado.info"));
			email.setOutlookID("jennifer.gates@macrowat.bodado.info");
			email.setSubject("Request for brochures and video demonstrations");
			email.setSender("jennifer.gates@macrowat.bodado.info");
			email.setRecipient("xueshan.tan@croks.bodado.info");			
			email.setBody("Hi Susan," + "<br/><br/>" +" This is Jennifer Gates from MacroWat. I saw your advertisement on your latest product, the World Slimmest Watch Phone, and is wondering if you have more detailed product brochures or videos to share with us?" + "<br/><br/>" +"Best Regards" + "<br/>" +"Jennifer Gates" + "<br/>" +"Purchasing Manager" + "<br/>" +"Watson, Inc.");
			email.setNotes(null);
			email.setStatus("New Message!");
			email.setConversationID(retrieveConversationID(email));
			createEmail(email);
			
			email = new Email();
			email.setTimestamp("7/12/2011 10:45:01 AM Pacific Daylight Time");
			email.setUserID(userDAO.getUserIDByEmail("xueshan.tan@croks.bodado.info"));
			email.setOutlookID("xueshan.tan@croks.bodado.info");
			email.setSubject("Request for brochures and video demonstrations");
			email.setSender("jennifer.gates@macrowat.bodado.info");
			email.setRecipient("xueshan.tan@croks.bodado.info");			
			email.setBody("Hi Susan," + "<br/><br/>" +" This is Jennifer Gates from MacroWat. I saw your advertisement on your latest product, the World Slimmest Watch Phone, and is wondering if you have more detailed product brochures or videos to share with us?" + "<br/><br/>" +"Best Regards" + "<br/>" +"Jennifer Gates" + "<br/>" +"Purchasing Manager" + "<br/>" +"Watson, Inc.");
			email.setNotes(null);
			email.setStatus("New Message!");
			email.setConversationID(retrieveConversationID(email));
			createEmail(email);
			
			//Set 2
			email = new Email();
			email.setTimestamp("7/13/2011 02:00:01 PM Eastern Standard Time");
			email.setUserID(userDAO.getUserIDByEmail("xueshan.tan@croks.bodado.info"));
			email.setOutlookID("xueshan.tan@croks.bodado.info");
			email.setSubject("Request for brochures and video demonstrations");
			email.setSender("xueshan.tan@croks.bodado.info");
			email.setRecipient("jennifer.gates@macrowat.bodado.info");			
			email.setBody("Hi Jennifer," + "<br/><br/>" +" Thank you for showing such strong interest in our new product. We have received a significant amount of feedbacks requesting for more product details and video demonstration from other clients as well. Once we have those materials ready, we would notify you immediately.Thank you for your patience." + "<br/><br/>" +"Best Regards" + "<br/>" +"Susan Tan" + "<br/>" +"Sales and Marketing Manager" + "<br/>" +"WatchFactory, Inc.");
			email.setNotes(null);
			email.setStatus("New Message!");
			email.setConversationID(retrieveConversationID(email));
			createEmail(email);
			
			email = new Email();
			email.setTimestamp("7/13/2011 02:00:01 PM Eastern Standard Time");
			email.setUserID(userDAO.getUserIDByEmail("jennifer.gates@macrowat.bodado.info"));
			email.setOutlookID("jennifer.gates@macrowat.bodado.info");
			email.setSubject("Request for brochures and video demonstrations");
			email.setSender("xueshan.tan@croks.bodado.info");
			email.setRecipient("jennifer.gates@macrowat.bodado.info");			
			email.setBody("Hi Jennifer," + "<br/><br/>" +" Thank you for showing such strong interest in our new product. We have received a significant amount of feedbacks requesting for more product details and video demonstration from other clients as well. Once we have those materials ready, we would notify you immediately.Thank you for your patience." + "<br/><br/>" +"Best Regards" + "<br/>" +"Susan Tan" + "<br/>" +"Sales and Marketing Manager" + "<br/>" +"WatchFactory, Inc.");
			email.setNotes(null);
			email.setStatus("New Message!");
			email.setConversationID(retrieveConversationID(email));
			createEmail(email);
			
			//Set 3
			email = new Email();
			email.setTimestamp("8/13/2011 8:30:01 AM Pacific Daylight Time");
			email.setUserID(userDAO.getUserIDByEmail("jennifer.gates@macrowat.bodado.info"));
			email.setOutlookID("jennifer.gates@macrowat.bodado.info");
			email.setSubject("Request for brochures and video demonstrations");
			email.setSender("jennifer.gates@macrowat.bodado.info");
			email.setRecipient("xueshan.tan@croks.bodado.info");			
			email.setBody("Hi Susan," + "<br/><br/>" +"  Thank you. We would love to hear from you soon." + "<br/><br/>" +"Best Regards" + "<br/>" +"Jennifer Gates" + "<br/>" +"Purchasing Manager" + "<br/>" +"Watson, Inc.");
			email.setNotes(null);
			email.setStatus("New Message!");
			email.setConversationID(retrieveConversationID(email));
			createEmail(email);
			
			email = new Email();
			email.setTimestamp("8/13/2011 8:30:01 AM Pacific Daylight Time");
			email.setUserID(userDAO.getUserIDByEmail("xueshan.tan@croks.bodado.info"));
			email.setOutlookID("xueshan.tan@croks.bodado.info");
			email.setSubject("Request for brochures and video demonstrations");
			email.setSender("jennifer.gates@macrowat.bodado.info");
			email.setRecipient("xueshan.tan@croks.bodado.info");			
			email.setBody("Hi Susan," + "<br/><br/>" +"  Thank you. We would love to hear from you soon." + "<br/><br/>" +"Best Regards" + "<br/>" +"Jennifer Gates" + "<br/>" +"Purchasing Manager" + "<br/>" +"Watson, Inc.");
			email.setNotes(null);
			email.setStatus("New Message!");
			email.setConversationID(retrieveConversationID(email));
			createEmail(email);
			
			//Set 4
			email = new Email();
			email.setTimestamp("8/14/2011 02:00:01 PM Eastern Standard Time");
			email.setUserID(userDAO.getUserIDByEmail("xueshan.tan@croks.bodado.info"));
			email.setOutlookID("xueshan.tan@croks.bodado.info");
			email.setSubject("Request for brochures and video demonstrations");
			email.setSender("xueshan.tan@croks.bodado.info");
			email.setRecipient("jennifer.gates@macrowat.bodado.info");			
			email.setBody("Hi Jennifer," + "<br/><br/>" +" We uploaded some new brochures and video demonstration for our World-slimmest watch phone onto the GlobaTrek platform. Please review it at your convenience. For any additional questions or feedback, please feel free to contact me via any form of communication, and I will be there to give you a quick response." + "<br/><br/>" +"Best Regards" + "<br/>" +"Susan Tan" + "<br/>" +"Sales and Marketing Manager" + "<br/>" +"WatchFactory, Inc.");
			email.setNotes(null);
			email.setStatus("New Message!");
			email.setConversationID(retrieveConversationID(email));
			createEmail(email);
			
			email = new Email();
			email.setTimestamp("8/14/2011 02:00:01 PM Eastern Standard Time");
			email.setUserID(userDAO.getUserIDByEmail("jennifer.gates@macrowat.bodado.info"));
			email.setOutlookID("jennifer.gates@macrowat.bodado.info");
			email.setSubject("Request for brochures and video demonstrations");
			email.setSender("xueshan.tan@croks.bodado.info");
			email.setRecipient("jennifer.gates@macrowat.bodado.info");			
			email.setBody("Hi Jennifer," + "<br/><br/>" +" We uploaded some new brochures and video demonstration for our World-slimmest watch phone onto the GlobaTrek platform. Please review it at your convenience. For any additional questions or feedback, please feel free to contact me via any form of communication, and I will be there to give you a quick response." + "<br/><br/>" +"Best Regards" + "<br/>" +"Susan Tan" + "<br/>" +"Sales and Marketing Manager" + "<br/>" +"WatchFactory, Inc.");
			email.setNotes(null);
			email.setStatus("New Message!");
			email.setConversationID(retrieveConversationID(email));
			createEmail(email);
			
			//Hae Jeong
			//Set 1
			email = new Email();
			email.setTimestamp("8/18/2011 11:19:12 AM Greenwich Mean Time");
			email.setUserID(userDAO.getUserIDByEmail("hae.jeong@watson.bodado.info"));
			email.setOutlookID("hae.jeong@watson.bodado.info");
			email.setSubject("DX Uncrushable C100 Product Enquiry");
			email.setSender("hae.jeong@watson.bodado.info");
			email.setRecipient("xueshan.tan@croks.bodado.info");			
			email.setBody("Hi Susan," + "<br/><br/>" +" This is Hae Jeong from Watson. I saw your advertisement on DX Uncrushable C100 and have generated intense interest in it. However, may I enquire on what is the extent of damage that the watch can manage?" + "<br/><br/>" +"Best Regards" + "<br/>" +"Hae Jeong" + "<br/>" +"Purchaser" + "<br/>" +"Watson, Inc.");
			email.setNotes(null);
			email.setStatus("New Message!");
			email.setConversationID(retrieveConversationID(email));
			createEmail(email);
			
			email = new Email();
			email.setTimestamp("8/18/2011 11:19:12 AM Greenwich Mean Time");
			email.setUserID(userDAO.getUserIDByEmail("xueshan.tan@croks.bodado.info"));
			email.setOutlookID("xueshan.tan@croks.bodado.info");
			email.setSubject("DX Uncrushable C100 Product Enquiry");
			email.setSender("hae.jeong@watson.bodado.info");
			email.setRecipient("xueshan.tan@croks.bodado.info");			
			email.setBody("Hi Susan," + "<br/><br/>" +" This is Hae Jeong from Watson. I saw your advertisement on DX Uncrushable C100 and have generated intense interest in it. However, may I enquire on what is the extent of damage that the watch can manage?" + "<br/><br/>" +"Best Regards" + "<br/>" +"Hae Jeong" + "<br/>" +"Purchaser" + "<br/>" +"Watson, Inc.");
			email.setNotes(null);
			email.setStatus("New Message!");
			email.setConversationID(retrieveConversationID(email));
			createEmail(email);
			
			//Set 2
			email = new Email();
			email.setTimestamp("8/18/2011 02:00:01 PM Eastern Standard Time");
			email.setUserID(userDAO.getUserIDByEmail("xueshan.tan@croks.bodado.info"));
			email.setOutlookID("xueshan.tan@croks.bodado.info");
			email.setSubject("DX Uncrushable C100 Product Enquiry");
			email.setSender("xueshan.tan@croks.bodado.info");
			email.setRecipient("hae.jeong@watson.bodado.info");			
			email.setBody("Hi Hae Jeong, " + "<br/><br/>" +" the watch is designed to handle the weight of an average car weighing from 1.5 to 2 tones. Hope it helps." + "<br/><br/>" +"Best Regards" + "<br/>" +"Susan Tan" + "<br/>" +"Sales and Marketing Manager" + "<br/>" +"WatchFactory, Inc.");
			email.setNotes(null);
			email.setStatus("New Message!");
			email.setConversationID(retrieveConversationID(email));
			createEmail(email);
			
			email = new Email();
			email.setTimestamp("8/18/2011 02:00:01 PM Eastern Standard Time");
			email.setUserID(userDAO.getUserIDByEmail("hae.jeong@watson.bodado.info"));
			email.setOutlookID("hae.jeong@watson.bodado.info");
			email.setSubject("DX Uncrushable C100 Product Enquiry");
			email.setSender("xueshan.tan@croks.bodado.info");
			email.setRecipient("hae.jeong@watson.bodado.info");			
			email.setBody("Hi Hae Jeong, " + "<br/><br/>" +" the watch is designed to handle the weight of an average car weighing from 1.5 to 2 tones. Hope it helps." + "<br/><br/>" +"Best Regards" + "<br/>" +"Susan Tan" + "<br/>" +"Sales and Marketing Manager" + "<br/>" +"WatchFactory, Inc.");
			email.setNotes(null);
			email.setStatus("New Message!");
			email.setConversationID(retrieveConversationID(email));
			createEmail(email);
			
			//Alice Braga
			//Set 1
			email = new Email();
			email.setTimestamp("8/19/2011 11:00:01 AM Atlantic Standard Time");
			email.setUserID(userDAO.getUserIDByEmail("alice.braga@hutchinsonnova.bodado.info"));
			email.setOutlookID("alice.braga@hutchinsonnova.bodado.info");
			email.setSubject("DX Uncrushable C100 Questions");
			email.setSender("alice.braga@hutchinsonnova.bodado.info");
			email.setRecipient("xueshan.tan@croks.bodado.info");			
			email.setBody("Hi Susan," + "<br/><br/>" +" This is Alice Braga from Hutchinson Nova. I saw your advertisement on the on DX Uncrushable C100 and have generated intense interest in it. However, may I enquire on what is the extent of damage that the watch can manage?" + "<br/><br/>" +"Best Regards" + "<br/>" +"Alice Braga" + "<br/>" +"Purchaser" + "<br/>" +"Hutchinson Technology");
			email.setNotes(null);
			email.setStatus("New Message!");
			email.setConversationID(retrieveConversationID(email));
			createEmail(email);
			
			email = new Email();
			email.setTimestamp("8/19/2011 11:00:01 AM Atlantic Standard Time");
			email.setUserID(userDAO.getUserIDByEmail("xueshan.tan@croks.bodado.info"));
			email.setOutlookID("xueshan.tan@croks.bodado.info");
			email.setSubject("DX Uncrushable C100 Questions");
			email.setSender("alice.braga@hutchinsonnova.bodado.info");
			email.setRecipient("xueshan.tan@croks.bodado.info");			
			email.setBody("Hi Susan," + "<br/><br/>" +" This is Alice Braga from Hutchinson Nova. I saw your advertisement on the on DX Uncrushable C100 and have generated intense interest in it. However, may I enquire on what is the extent of damage that the watch can manage?" + "<br/><br/>" +"Best Regards" + "<br/>" +"Alice Braga" + "<br/>" +"Purchaser" + "<br/>" +"Hutchinson Technology");
			email.setNotes(null);
			email.setStatus("New Message!");
			email.setConversationID(retrieveConversationID(email));
			createEmail(email);
			
			//Set 2
			email = new Email();
			email.setTimestamp("8/19/2011 2:00:01 PM Eastern Standard Time");
			email.setUserID(userDAO.getUserIDByEmail("xueshan.tan@croks.bodado.info"));
			email.setOutlookID("xueshan.tan@croks.bodado.info");
			email.setSubject("DX Uncrushable C100 Questions");
			email.setSender("xueshan.tan@croks.bodado.info");
			email.setRecipient("alice.braga@hutchinsonnova.bodado.info");			
			email.setBody("Hi Alice," + "<br/><br/>" +" The watch is designed to handle the weight of an average car weighing from 1.5 to 2 tones. Hope it helps." + "<br/><br/>" +"Best Regards" + "<br/>" +"Susan Tan" + "<br/>" +"Sales and Marketing Manager" + "<br/>" +"WatchFactory, Inc.");
			email.setNotes(null);
			email.setStatus("New Message!");
			email.setConversationID(retrieveConversationID(email));
			createEmail(email);
			
			email = new Email();
			email.setTimestamp("8/19/2011 2:00:01 PM Eastern Standard Time");
			email.setUserID(userDAO.getUserIDByEmail("alice.braga@hutchinsonnova.bodado.info"));
			email.setOutlookID("alice.braga@hutchinsonnova.bodado.info");
			email.setSubject("DX Uncrushable C100 Questions");
			email.setSender("xueshan.tan@croks.bodado.info");
			email.setRecipient("alice.braga@hutchinsonnova.bodado.info");			
			email.setBody("Hi Alice," + "<br/><br/>" +" The watch is designed to handle the weight of an average car weighing from 1.5 to 2 tones. Hope it helps." + "<br/><br/>" +"Best Regards" + "<br/>" +"Susan Tan" + "<br/>" +"Sales and Marketing Manager" + "<br/>" +"WatchFactory, Inc.");
			email.setNotes(null);
			email.setStatus("New Message!");
			email.setConversationID(retrieveConversationID(email));
			createEmail(email);
			
			//John Kani
			//Set 1
			email = new Email();
			email.setTimestamp("8/20/2011 11:00:01 AM South Africa Standard Time");
			email.setUserID(userDAO.getUserIDByEmail("john.kani@pcnwatchmax.bodado.info"));
			email.setOutlookID("john.kani@pcnwatchmax.bodado.info");
			email.setSubject("DX Uncrushable C100 Specs Doubts");
			email.setSender("john.kani@pcnwatchmax.bodado.info");
			email.setRecipient("xueshan.tan@croks.bodado.info");			
			email.setBody("Hi Susan," + "<br/><br/>" +" This is John Kani from PCN WatchMax. I saw your advertisement on the on DX Uncrushable C100 and have generated intense interest in it. However, may I enquire on what is the extent of damage that the watch can manage?" + "<br/><br/>" +"Best Regards" + "<br/>" +"John Kani" + "<br/>" +"Purchaser" + "<br/>" +"PCN WatchMax");
			email.setNotes(null);
			email.setStatus("New Message!");
			email.setConversationID(retrieveConversationID(email));
			createEmail(email);
			
			email = new Email();
			email.setTimestamp("8/20/2011 11:00:01 AM South Africa Standard Time");
			email.setUserID(userDAO.getUserIDByEmail("xueshan.tan@croks.bodado.info"));
			email.setOutlookID("xueshan.tan@croks.bodado.info");
			email.setSubject("DX Uncrushable C100 Specs Doubts");
			email.setSender("john.kani@pcnwatchmax.bodado.info");
			email.setRecipient("xueshan.tan@croks.bodado.info");			
			email.setBody("Hi Susan," + "<br/><br/>" +" This is John Kani from PCN WatchMax. I saw your advertisement on the on DX Uncrushable C100 and have generated intense interest in it. However, may I enquire on what is the extent of damage that the watch can manage?" + "<br/><br/>" +"Best Regards" + "<br/>" +"John Kani" + "<br/>" +"Purchaser" + "<br/>" +"PCN WatchMax");
			email.setNotes(null);
			email.setStatus("New Message!");
			email.setConversationID(retrieveConversationID(email));
			createEmail(email);
			
			
			//Malika Gopal
			//Set 1
			email = new Email();
			email.setTimestamp("8/21/2011 09:00:01 AM Western Indonesian Time");
			email.setUserID(userDAO.getUserIDByEmail("malika.gopal@ambersonwatchtech.bodado.info"));
			email.setOutlookID("malika.gopal@ambersonwatchtech.bodado.info");
			email.setSubject("DX Uncrushable C100 Batch Order");
			email.setSender("malika.gopal@ambersonwatchtech.bodado.info");
			email.setRecipient("xueshan.tan@croks.bodado.info");			
			email.setBody("Hi Susan," + "<br/><br/>" +"This is Malika Gopal from Amberson WatchTech. I saw your advertisement on the on DX Uncrushable C100 and have generated intense interest in it. However, may I enquire on what is the extent of damage that the watch can manage?" + "<br/><br/>" +"Best Regards" + "<br/>" +"Malika Gopal" + "<br/>" +"Purchaser" + "<br/>" +"Amberson WatchTech");
			email.setNotes(null);
			email.setStatus("New Message!");
			email.setConversationID(retrieveConversationID(email));
			createEmail(email);
			
			email = new Email();
			email.setTimestamp("8/21/2011 09:00:01 AM Western Indonesian Time");
			email.setUserID(userDAO.getUserIDByEmail("xueshan.tan@croks.bodado.info"));
			email.setOutlookID("xueshan.tan@croks.bodado.info");
			email.setSubject("DX Uncrushable C100 Batch Order");
			email.setSender("malika.gopal@ambersonwatchtech.bodado.info");
			email.setRecipient("xueshan.tan@croks.bodado.info");			
			email.setBody("Hi Susan," + "<br/><br/>" +"This is Malika Gopal from Amberson WatchTech. I saw your advertisement on the on DX Uncrushable C100 and have generated intense interest in it. However, may I enquire on what is the extent of damage that the watch can manage?" + "<br/><br/>" +"Best Regards" + "<br/>" +"Malika Gopal" + "<br/>" +"Purchaser" + "<br/>" +"Amberson WatchTech");
			email.setNotes(null);
			email.setStatus("New Message!");
			email.setConversationID(retrieveConversationID(email));
			createEmail(email);
			
			//Set 2
			email = new Email();
			email.setTimestamp("8/21/2011 02:00:01 PM Eastern Standard Time");
			email.setUserID(userDAO.getUserIDByEmail("xueshan.tan@croks.bodado.info"));
			email.setOutlookID("xueshan.tan@croks.bodado.info");
			email.setSubject("DX Uncrushable C100 Batch Order");
			email.setSender("xueshan.tan@croks.bodado.info");
			email.setRecipient("malika.gopal@ambersonwatchtech.bodado.info");			
			email.setBody("Hi Malika," + "<br/><br/>" +" The watch is designed to handle the weight of an average car weighing from 1.5 to 2 tones. Hope it helps." + "<br/><br/>" +"Best Regards" + "<br/>" +"Susan Tan" + "<br/>" +"Sales and Marketing Manager" + "<br/>" +"WatchFactory, Inc.");
			email.setNotes(null);
			email.setStatus("New Message!");
			email.setConversationID(retrieveConversationID(email));
			createEmail(email);
			
			email = new Email();
			email.setTimestamp("8/21/2011 02:00:01 PM Eastern Standard Time");
			email.setUserID(userDAO.getUserIDByEmail("malika.gopal@ambersonwatchtech.bodado.info"));
			email.setOutlookID("malika.gopal@ambersonwatchtech.bodado.info");
			email.setSubject("DX Uncrushable C100 Batch Order");
			email.setSender("xueshan.tan@croks.bodado.info");
			email.setRecipient("malika.gopal@ambersonwatchtech.bodado.info");			
			email.setBody("Hi Malika," + "<br/><br/>" +" The watch is designed to handle the weight of an average car weighing from 1.5 to 2 tones. Hope it helps." + "<br/><br/>" +"Best Regards" + "<br/>" +"Susan Tan" + "<br/>" +"Sales and Marketing Manager" + "<br/>" +"WatchFactory, Inc.");
			email.setNotes(null);
			email.setStatus("New Message!");
			email.setConversationID(retrieveConversationID(email));
			createEmail(email);
			
			//Huang Li email conversations	
			//Set 1
			email = new Email();
			email.setTimestamp("8/23/2011 10:00:01 AM Eastern Standard Time");
			email.setUserID(userDAO.getUserIDByEmail("li.huang@innova.bodado.info"));
			email.setOutlookID("li.huang@innova.bodado.info");
			email.setSubject("World Slimmest Watch Phone Order Enquiry");
			email.setSender("li.huang@innova.bodado.info");
			email.setRecipient("xueshan.tan@croks.bodado.info");			
			email.setBody("Hi Susan," + "<br/><br/>" +"This is Li Huang from Watson. We saw your latest product, the World Slimmest Watch Phone through the GlobaTrek network and would like to enquire on the price offering for a 3000 pieces batch order." + "<br/><br/>" +"Best Regards" + "<br/>" +"Huang Li" + "<br/>" +"Purchasing Director" + "<br/>" +"Innova, Inc.");
			email.setNotes(null);
			email.setStatus("New Message!");
			email.setConversationID(retrieveConversationID(email));
			createEmail(email);
			
			email = new Email();
			email.setTimestamp("8/23/2011 10:00:01 AM Eastern Standard Time");
			email.setUserID(userDAO.getUserIDByEmail("xueshan.tan@croks.bodado.info"));
			email.setOutlookID("xueshan.tan@croks.bodado.info");
			email.setSubject("World Slimmest Watch Phone Order Enquiry");
			email.setSender("li.huang@innova.bodado.info");
			email.setRecipient("xueshan.tan@croks.bodado.info");			
			email.setBody("Hi Susan," + "<br/><br/>" +"This is Li Huang from Watson. We saw your latest product, the World Slimmest Watch Phone through the GlobaTrek network and would like to enquire on the price offering for a 3000 pieces batch order." + "<br/><br/>" +"Best Regards" + "<br/>" +"Huang Li" + "<br/>" +"Purchasing Director" + "<br/>" +"Innova, Inc.");
			email.setNotes(null);
			email.setStatus("New Message!");
			email.setConversationID(retrieveConversationID(email));
			createEmail(email);
			
			//Set 2
			email = new Email();
			email.setTimestamp("8/24/2011 04:00:01 PM Eastern Standard Time");
			email.setUserID(userDAO.getUserIDByEmail("xueshan.tan@croks.bodado.info"));
			email.setOutlookID("xueshan.tan@croks.bodado.info");
			email.setSubject("World Slimmest Watch Phone Order Enquiry");
			email.setSender("xueshan.tan@croks.bodado.info");
			email.setRecipient("li.huang@innova.bodado.info");			
			email.setBody("Hi Li," + "<br/><br/>" +" For that quantity, we charge it at a price of 300 USD for each watch." + "<br/><br/>" +"Best Regards" + "<br/>" +"Huang Li" + "<br/>" +"Sales and Marketing Manager" + "<br/>" +"WatchFactory, Inc.");
			email.setNotes(null);
			email.setStatus("New Message!");
			email.setConversationID(retrieveConversationID(email));
			createEmail(email);
			
			email = new Email();
			email.setTimestamp("8/24/2011 04:00:01 PM Eastern Standard Time");
			email.setUserID(userDAO.getUserIDByEmail("li.huang@innova.bodado.info"));
			email.setOutlookID("li.huang@innova.bodado.info");
			email.setSubject("World Slimmest Watch Phone Order Enquiry");
			email.setSender("xueshan.tan@croks.bodado.info");
			email.setRecipient("li.huang@innova.bodado.info");			
			email.setBody("Hi Li," + "<br/><br/>" +" For that quantity, we charge it at a price of 300 USD for each watch." + "<br/><br/>" +"Best Regards" + "<br/>" +"Huang Li" + "<br/>" +"Sales and Marketing Manager" + "<br/>" +"WatchFactory, Inc.");
			email.setNotes(null);
			email.setStatus("New Message!");
			email.setConversationID(retrieveConversationID(email));
			createEmail(email);
			
			//Set 3
			email = new Email();
			email.setTimestamp("8/25/2011 10:00:01 AM Eastern Standard Time");
			email.setUserID(userDAO.getUserIDByEmail("li.huang@innova.bodado.info"));
			email.setOutlookID("li.huang@innova.bodado.info");
			email.setSubject("World Slimmest Watch Phone Order Enquiry");
			email.setSender("li.huang@innova.bodado.info");
			email.setRecipient("xueshan.tan@croks.bodado.info");			
			email.setBody("Hi Susan," + "<br/><br/>" +"Is there any room for negotiation?" + "<br/><br/>" +"Best Regards" + "<br/>" +"Huang Li" + "<br/>" +"Purchasing Director" + "<br/>" +"Innova, Inc.");
			email.setNotes(null);
			email.setStatus("New Message!");
			email.setConversationID(retrieveConversationID(email));
			createEmail(email);
			
			email = new Email();
			email.setTimestamp("8/25/2011 10:00:01 AM Eastern Standard Time");
			email.setUserID(userDAO.getUserIDByEmail("xueshan.tan@croks.bodado.info"));
			email.setOutlookID("xueshan.tan@croks.bodado.info");
			email.setSubject("World Slimmest Watch Phone Order Enquiry");
			email.setSender("li.huang@innova.bodado.info");
			email.setRecipient("xueshan.tan@croks.bodado.info");			
			email.setBody("Hi Susan," + "<br/><br/>" +"Is there any room for negotiation?" + "<br/><br/>" +"Best Regards" + "<br/>" +"Huang Li" + "<br/>" +"Purchasing Director" + "<br/>" +"Innova, Inc.");
			email.setNotes(null);
			email.setStatus("New Message!");
			email.setConversationID(retrieveConversationID(email));
			createEmail(email);
			
			//Set 4
			email = new Email();
			email.setTimestamp("8/25/2011 3:00:01 PM Eastern Standard Time");
			email.setUserID(userDAO.getUserIDByEmail("xueshan.tan@croks.bodado.info"));
			email.setOutlookID("xueshan.tan@croks.bodado.info");
			email.setSubject("World Slimmest Watch Phone Order Enquiry");
			email.setSender("xueshan.tan@croks.bodado.info");
			email.setRecipient("li.huang@innova.bodado.info");			
			email.setBody("Hi Li," + "<br/><br/>" +" We are open for discussion, but may I know what is your proposed price?" + "<br/><br/>" +"Best Regards" + "<br/>" +"Huang Li" + "<br/>" +"Sales and Marketing Manager" + "<br/>" +"WatchFactory, Inc.");
			email.setNotes(null);
			email.setStatus("New Message!");
			email.setConversationID(retrieveConversationID(email));
			createEmail(email);
			
			email = new Email();
			email.setTimestamp("8/25/2011 3:00:01 PM Eastern Standard Time");
			email.setUserID(userDAO.getUserIDByEmail("li.huang@innova.bodado.info"));
			email.setOutlookID("li.huang@innova.bodado.info");
			email.setSubject("World Slimmest Watch Phone Order Enquiry");
			email.setSender("xueshan.tan@croks.bodado.info");
			email.setRecipient("li.huang@innova.bodado.info");			
			email.setBody("Hi Li," + "<br/><br/>" +" We are open for discussion, but may I know what is your proposed price?" + "<br/><br/>" +"Best Regards" + "<br/>" +"Huang Li" + "<br/>" +"Sales and Marketing Manager" + "<br/>" +"WatchFactory, Inc.");
			email.setNotes(null);
			email.setStatus("New Message!");
			email.setConversationID(retrieveConversationID(email));
			createEmail(email); */
			
			//Li Du 
			//Set 1
			email = new Email();
			email.setTimestamp("08/24/2011 11:30:01 AM China Standard Time");
			email.setUserID(userDAO.getUserIDByEmail("li.du@tenwest.bodado.info"));
			email.setOutlookID("li.du@tenwest.bodado.info");
			email.setSubject("Pinky Malika Product Enquiry");
			email.setSender("li.du@tenwest.bodado.info");
			email.setRecipient("xueshan.tan@croks.bodado.info");			
			email.setBody(stringToHTMLString("嗨雪珊,") + "<br/><br/>" +stringToHTMLString("我叫丽，我看到你的 商品“pinky mallika” 在GLOBATREK, 并正在考虑购买它作为一款旗舰产品。你能否提供更详细的信息,购买？") + "<br/><br/>" +"Best Regards" + "<br/>" +"Li Du" + "<br/>" +"Purchasing Manager" + "<br/>" +"Ten West,Inc.");
			email.setNotes(null);
			email.setStatus("New Message From Outlook!");
			email.setConversationID(retrieveConversationID(email));
			createEmail(email);
			
			email = new Email();
			email.setTimestamp("08/24/2011 11:30:01 AM China Standard Time");
			email.setUserID(userDAO.getUserIDByEmail("xueshan.tan@croks.bodado.info"));
			email.setOutlookID("xueshan.tan@croks.bodado.info");
			email.setSubject("Pinky Mallika Product Enquiry");
			email.setSender("li.du@tenwest.bodado.info");
			email.setRecipient("xueshan.tan@croks.bodado.info");			
			email.setBody(stringToHTMLString("嗨雪珊,") + "<br/><br/>" +stringToHTMLString("我叫丽，我看到你的 商品“pinky mallika” 在GLOBATREK, 并正在考虑购买它作为一款旗舰产品。你能否提供更详细的商品信息？") + "<br/><br/>" +"Best Regards" + "<br/>" +"Li Du" + "<br/>" +"Purchasing Manager" + "<br/>" +"Ten West,Inc.");
			email.setNotes(null);
			email.setStatus("New Message From Outlook!");
			email.setConversationID(retrieveConversationID(email));
			createEmail(email);
			
	
		} catch (SQLException e) {
			e.printStackTrace();
		}
		
		
	}
	
}
